import axios from 'axios'

export function request(config) {
	const instance = axios.create({
		baseURL: 'http://127.0.0.1:8083',
		timeout: 10000,
	})

	// 请求拦截器
	instance.interceptors.request.use(
		(config) => {
			config.withCredentials = true
			return config
		},
		(error) => {
			return Promise.rejct(error)
		}
	)

	//响应拦截器
	instance.interceptors.response.use(
		(response) => {
			return response.data
		},
		(error) => {
			return error.response.data
		}
	)

	// 发送网络请求
	return instance(config)
}
